innerapp.controller('login_Ctrl', ['$scope', '$rootScope', '$http', '$cookies', '$location', function ($scope, $rootScope,$http,$cookies,$location) {
    $scope.username = $cookies.get("userName");
    $scope.password = $cookies.get("password");
    $cookies.get("userLevel");
    if(typeof ($scope.username) != "string"){
        $scope.username = "";
    }
    if(typeof ($scope.password) != "string"){
        $scope.password = "" ;       
    }
    $scope.login = function () {
        $http.get("/Service/login/checkLogin/?user=" + $scope.username + "&password=" + gfhdjkagf($scope.password))
            .then(function (result) {
                if (result.data != null && typeof (result.data) != "undefined" && typeof (result.data) != "string") {
                    if (result.data.Name != null && typeof (result.data.Name) != "undefined" && result.data.Level != null && typeof (result.data.Level) != "undefined") {
                        var expireDate = new Date();
                        expireDate.setDate(expireDate.getDate() + 7);
                        $cookies.put("userName",result.data.Name,{'expires': expireDate});//"userName"一天后过期
                        $cookies.put("password",$scope.password,{'expires': expireDate});//"userName"一天后过期
                        $cookies.put("userLevel",result.data.Level,{'expires': expireDate});//"userName"一天后过期
                        $rootScope.user = result.data.Name;
                        $location.path("../");
                    }
                    else{
                        alert("登陆失败。请检查用户名密码");
                    }
                }
                else{
                    alert("登陆失败。请检查用户名密码");
                }
            });
    }
}])